<?php
declare (strict_types = 1);

namespace app\command;

use app\wsns\service\RabbitMQConsumer;
use think\console\Command;
use think\console\Input;
use think\console\input\Argument;
use think\console\input\Option;
use think\console\Output;
use think\facade\Log;

class LGConsumeRabbitMQ extends Command
{
    protected function configure()
    {
        // 指令配置
        $this->setName('hello')
            ->setDescription('the lgconsumerabbitmq command');
    }

    protected function execute(Input $input, Output $output)
    {
        // 指令输出
        $output->writeln('lgconsumerabbitmq');
        $consumer = new RabbitMQConsumer();
//        $consumer->consume('luo', function ($message) {
//            $data = json_decode($message, true);
//            // 处理业务逻辑
//            echo "处理数据: " . $data['name'] . "\n";
//        });
        $consumer->consume('delayed.queue', function ($message) {

            // 处理业务逻辑
            Log::info("命令行持续工作-信息为 $message");
            echo "tp命令处理数据: " . $message . "\n";

        });
    }
}
